/**
 * MarioEnemy_GoombaAI
 * @extends MarioAI_Patrol
 * @version 2010.12.04
 */

class MarioEnemy_GoombaAI extends MarioAI_Patrol;

auto state FollowPath
{
	/**
	 * SeePlayer
	 * @version 2010.12.04
	 */
	event SeePlayer(Pawn SeenPlayer)
	{
	    thePlayer = SeenPlayer;
    }

	Begin:
	Pawn.MaxDesiredSpeed = 0.3;

	while(followingPath)
	{
		MoveTarget = MyNavigationPoints[actual_node];
		
		if(Pawn.ReachedDestination(MoveTarget))
		{
			//WorldInfo.Game.Broadcast(self, "Encontrei o node");
			actual_node++;
			
			if (actual_node >= MyNavigationPoints.Length)
			{
				actual_node = 0;
			}
			last_node = actual_node;
			
			MoveTarget = MyNavigationPoints[actual_node];
		}	

		if (ActorReachable(MoveTarget))
		{
			//distanceToPlayer = VSize(MoveTarget.Location - Pawn.Location);
			//if (distanceToPlayer < perceptionDistance / 3)
			//	MoveToward(MoveTarget, MyNavigationPoints[actual_node + 1]);	
			//else
				MoveToward(MoveTarget, MoveTarget);	
		}
		else
		{
			MoveTarget = FindPathToward(MyNavigationPoints[actual_node]);
			if (MoveTarget != none)
			{
				
				//SetRotation(RInterpTo(Rotation,Rotator(MoveTarget.Location),Delta,90000,true));
				
				MoveToward(MoveTarget, MoveTarget);
			}
		}

		Sleep(1);
	}
}